package com.neusoft.tyut.bu;

public class Emp {
    private Integer empno;
    private String ename;
    private String job;

    public Emp(Integer empno, String ename, String job) {
        this.empno = empno;
        this.ename = ename;
        this.job = job;
    }

    @Override
    public String toString() {
        return "Emp{" +
                "empno=" + empno +
                ", ename='" + ename + '\'' +
                ", job='" + job + '\'' +
                '}';
    }

    public static EmpBuilder builder()
    {
        return new EmpBuilder();
    }
    private static  final class EmpBuilder{
        private Integer empno = 7369;
        private String ename;
        private String job;

        public EmpBuilder empno(Integer  empno){
            this.empno = empno;
            return  this;
        }
        public EmpBuilder ename(String  ename){
            this.ename = ename;
            return  this;
        }
        public EmpBuilder job(String  job){
            this.job  = job ;
            return  this;
        }
        public Emp build(){
            return new Emp(empno,ename,job);
        }
    }

    public static void main(String[] args) {
        Emp emp = (Emp.builder()).empno(7369)
                .ename("smith")
                .job("clerk")
                .build();
        System.out.println(emp);
    }

    public static void main1(String[] args) {
        EmpBuilder builder =  Emp.builder();
        builder = builder.empno(7369);
        builder = builder.ename("smith");
        builder = builder.job("clerk");
        Emp emp = builder.build();
        System.out.println(emp);
    }
}
